<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        //math数学对象 不是构造函数 所以不需要new调用 直接使用里面的属性和方法

        console.log(Math.PI); //一个属性-圆周率
        console.log(Math.max(1, 88, 6)); //方法 返回最大值

        //绝对值
        console.log(Math.abs(1)); //1
        console.log(Math.abs(-1)); //1
        console.log(Math.abs('-1')); //1 隐式转换 会把字符串 转换为数字型

        //取三个整数
        //1.向下取整 Math.floor
        console.log(Math.floor(1.1)); //1
        console.log(Math.floor(1.9)); //1
        //2.向上取整 Math.ceil
        console.log(Math.ceil(1.1)); //2
        console.log(Math.ceil(1.9)); //2
        //3.四舍五入 Math.round
        console.log(Math.round(1.1)); //1
        console.log(Math.round(1.5)); //2


        var myMath = {
            PI: 3.141592653,
            max: function() {
                var max = arguments[0]
                for (var i = 1; i < arguments.length; i++) {
                    if (arguments[i] > max) {
                        max = arguments[i];
                    }
                }
                return max;
            },
            min: function() {
                var min = arguments[0]
                for (var i = 1; i < arguments.length; i++) {
                    if (arguments[i] < min) {
                        min = arguments[i];
                    }
                }
                return min;
            }
        }
        console.log(myMath.PI);
        console.log(myMath.max(6, 5, 1));
    </script>
</head>

<body>

</body>

</html>